package com.leyou.web;

import com.leyou.service.PageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.Map;

/**
 * @author fenglin
 * @date 2019/12/19 16:21
 */

@Controller
public class PageController {
    @Autowired
    private PageService pageService;
    @GetMapping("/item/{id}.html")
    public String toItemPage(@PathVariable("id")Long spuId, Model model){
        // 根据spu的id查询各种数据
        Map<String, Object> itemData = pageService.loadItemData(spuId);
        // 把数据存入Model
        model.addAllAttributes(itemData);
        // 跳转到指定视图
        return "item";
    }
}
